#ifndef INTERPRETER_H
#define INTERPRETER_H
#include "secdvm.h"
#include<map>
#include<hash_map>




#include<list>

class InterpGc {
public:
    void *interp;
    std::list<Value *> *mempool;
    Value *NIL;
    void mark();
    void markAll();
    void sweep();
    Value *malloc(size_t);
    InterpGc(void*);

    ~InterpGc();
};

typedef struct Env{
    std::hash_map<char *, Value *> *hash;
    struct Env *uplevel;
} Env;

class Interpreter {
public:
    std::hash_map<char *, Value *> *TopLevel;
    Value *NIL;
    Value *makeSymbol(char *, int);
    Value *makeString(char *, int);
    Value *makeChar(char);
    Value *makeInteger(int);
    Value *makeFloat(float);
    Value *makeList(Value *, Value *);
    Value *cons(Value *a, Value *b);
    void registCFunc(char *, c_func);
    Value *car(Value *code);
    Value *cdr(Value *code);
    Value *eval(Value *code,Env *env);
    Value *run(Value *code);
    Value *apply(Value *sym, Value *code,Env *env);
    Value *loopup(Value *sym, Env *code);
    Env *Interpreter::makeEnv(std::hash_map<char *, Value *> *current); 
    InterpGc *gc;
    Interpreter();
    ~Interpreter();

};







#endif // INTERPRETER_H
